package com.xmutca.micro.uaa.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * Created by chunchengpeng on 17/7/28.
 */
@RestController
@RequestMapping("/api/test")
public class ProtectedController {

    @PreAuthorize("hasAuthority('USER')")
    @RequestMapping(value = "/1")
    public Object test() {
        return "test";
    }

    @PreAuthorize("hasAuthority('ADMIN')")
    @RequestMapping(value = "2")
    public Object test2() {
        return "test2";
    }

    @RequestMapping(value = "3")
    public Object test3(Principal principal) {
        System.out.println(principal);
        return "test3";
    }
}
